import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Input, Form } from 'antd';

export default class updateForm extends Component {
  formRef = React.createRef();

  componentDidMount() {
    this.props.getForm(this.formRef.current);
  }

  static propTypes = {
    getForm: PropTypes.func.isRequired,
    categoryName: PropTypes.string,
  };

  render() {
    const categoryName = this.props.categoryName;
    return (
      <div>
        <Form ref={this.formRef} name="update-form">
          <div>分类名称：</div>
          <Form.Item
            initialValue={categoryName}
            name="categoryName"
            rules={[{ required: true, message: 'Please input category name!' }]}
          >
            <Input
              placeholder="请在此处输入要更改的名称"
              style={{ marginTop: '1.9%' }}
            />
          </Form.Item>
        </Form>
      </div>
    );
  }
}
